package edu.hawaii.myisern.model;

/**
 * Encapsulates the researcher record.
 * 
 * @author Randy Cox
 * 
 */
public class MyResearcher {

  private Id id;
  private String name;
  private String email;
  private String organization;
  private String pictureLink;
  private String bio;

  /**
   * Initialize the data.
   */
  public MyResearcher() {
    initialize();
  }

  /**
   * Initialize and clear record.
   */
  public final void initialize() {
    this.id = new Id();
    this.name = "";
    this.email = "";
    this.organization = "";
    this.pictureLink = "";
    this.bio = "";
  }

  /**
   * @return the id
   */
  public String getId() {
    return id.toString();
  }

  /**
   * Gets name.
   * 
   * @return the name
   */
  public String getName() {
    return name;
  }

  /**
   * Sets name.
   * 
   * @param name the name to set
   */
  public void setName(String name) {
    this.id = new Id(name);
    this.name = name;
  }

  /**
   * Gets email.
   * 
   * @return the email
   */
  public String getEmail() {
    return email;
  }

  /**
   * Sets email.
   * 
   * @param email the email to set
   */
  public void setEmail(String email) {
    this.email = email;
  }

  /**
   * Gets organization.
   * 
   * @return the organization
   */
  public String getOrganization() {
    return organization;
  }

  /**
   * Sets organization.
   * 
   * @param organization the organization to set
   */
  public void setOrganization(String organization) {
    this.organization = organization;
  }

  /**
   * Gets picture link.
   * 
   * @return the pictureLink
   */
  public String getPictureLink() {
    return pictureLink;
  }

  /**
   * Sets picture link.
   * 
   * @param pictureLink the pictureLink to set
   */
  public void setPictureLink(String pictureLink) {
    this.pictureLink = pictureLink;
  }

  /**
   * Gets bio statement.
   * 
   * @return the bio
   */
  public String getBio() {
    return bio;
  }

  /**
   * Sets bio statement.
   * 
   * @param bio the bio to set
   */
  public void setBio(String bio) {
    this.bio = bio;
  }

  /**
   * Checks if record has id, name and email populated.
   * 
   * @return true if required fields are populated.
   */
  public Boolean validate() {
    Boolean ok = ((this.id != null) && (this.name != null) && (this.email != null)
        && (this.organization != null) && (this.pictureLink != null) && (this.bio != null));
    if (ok) {
      ok = ((!this.id.toString().isEmpty()) && (!this.name.isEmpty()) && (!this.email.isEmpty()));
    }
    return ok;
  }

  /**
   * Creates a string delimited by commas of the record contents.
   * 
   * @return string of record data.
   */
  public String toString() {
    String string = "";
    if (this.validate()) {
      String comma = ", ";
      string = getId() + comma + getName() + comma + getEmail() + comma + getOrganization() + comma
          + getPictureLink() + comma + getBio();
    }
    return string;
  }

}
